/**
    入驻小区
**/
(function(vc){
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data:{
            affiliateCommissionManageInfo:{
                affiliateCommissions:[],
                total:0,
                records:1,
                moreCondition:false,
                acId:'',
                conditions:{
                    commissionRate:'',

                }
            }
        },
        _initMethod:function(){
            vc.component._listAffiliateCommissions(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent:function(){

            vc.on('affiliateCommissionManage','listAffiliateCommission',function(_param){
                  vc.component._listAffiliateCommissions(DEFAULT_PAGE, DEFAULT_ROWS);
            });
             vc.on('pagination','page_event',function(_currentPage){
                vc.component._listAffiliateCommissions(_currentPage,DEFAULT_ROWS);
            });
        },
        methods:{
            _listAffiliateCommissions:function(_page, _rows){

                vc.component.affiliateCommissionManageInfo.conditions.page = _page;
                vc.component.affiliateCommissionManageInfo.conditions.row = _rows;
                var param = {
                    params:vc.component.affiliateCommissionManageInfo.conditions
               };

               //发送get请求
               vc.http.apiGet('affiliateCommission.listAffiliateCommission',
                             param,
                             function(json,res){
                                var _affiliateCommissionManageInfo=JSON.parse(json);
                                vc.component.affiliateCommissionManageInfo.total = _affiliateCommissionManageInfo.total;
                                vc.component.affiliateCommissionManageInfo.records = _affiliateCommissionManageInfo.records;
                                vc.component.affiliateCommissionManageInfo.affiliateCommissions = _affiliateCommissionManageInfo.data;
                                vc.emit('pagination','init',{
                                     total:vc.component.affiliateCommissionManageInfo.records,
                                     currentPage:_page
                                 });
                             },function(errInfo,error){
                                console.log('请求失败处理');
                             }
                           );
            },
            _openAddAffiliateCommissionModal:function(){
                vc.emit('addAffiliateCommission','openAddAffiliateCommissionModal',{});
            },
            _openEditAffiliateCommissionModel:function(_affiliateCommission){
                vc.emit('editAffiliateCommission','openEditAffiliateCommissionModal',_affiliateCommission);
            },
            _openDeleteAffiliateCommissionModel:function(_affiliateCommission){
                vc.emit('deleteAffiliateCommission','openDeleteAffiliateCommissionModal',_affiliateCommission);
            },
            _queryAffiliateCommissionMethod:function(){
                vc.component._listAffiliateCommissions(DEFAULT_PAGE, DEFAULT_ROWS);

            },
            _moreCondition:function(){
                if(vc.component.affiliateCommissionManageInfo.moreCondition){
                    vc.component.affiliateCommissionManageInfo.moreCondition = false;
                }else{
                    vc.component.affiliateCommissionManageInfo.moreCondition = true;
                }
            },
            _level: function (_state) {
                if(_state == "1"){
                    return "一级"
                }
                if(_state == "2"){
                    return "二级"
                }
            },
            _state: function (_state) {
                if(_state == "0"){
                    return "待结算"
                }
                if(_state == "1"){
                    return "已结算"
                }
                if(_state == "2"){
                    return "已取消"
                }
            },


        }
    });
})(window.vc);
